import request from '@/config/axios'

// 质检平台-承检资质 VO
export interface OrganizationQualificationVO {
  id: number // 主键id
  type: number // 证书类型: 0-CMA 1-CNAS 2-体系证书
  num: string // 证书编号
  licenceIssuingAuthority: string // 发证机关
  issueDate: Date // 发证时间
  expireTime: string // 有效日期
  attachment: string // 附件Url,多个用";"隔开 最多五个
  orgId: number // 机构id
}

// 下载检验报告
export const downloadReport = (id: number) => {
  return request.get({
    url: '/qis/inspection-report/download/' + id,
    responseType: 'blob'
  })
}

// 获取检验报告详情
export const getReportDetail = (id: number) => {
  return request.get({
    url: '/qis/inspection-report/detail/' + id
  })
}

// 质检平台-承检资质 API
export const OrganizationQualificationApi = {
  // 查询质检平台-承检资质分页
  getOrganizationQualificationPage: async (params: any) => {
    return await request.get({ url: `/qis/check-organization/page`, params })
  },

  getOrganizationQualificationPage1: async (params: any) => {
    return await request.get({ url: `/qis/check-organization/page-staff`, params })
  },

  // 查询质检平台-承检资质详情
  getOrganizationQualification: async (id: number) => {
    return await request.get({ url: `/qis/check-organization/get?id=` + id })
  },

  // 新增质检平台-承检资质
  createOrganizationQualification: async (data: OrganizationQualificationVO) => {
    return await request.post({ url: `/qis/check-organization/create`, data })
  },

  // 修改质检平台-承检资质
  updateOrganizationQualification: async (data: OrganizationQualificationVO) => {
    return await request.put({ url: `/qis/check-organization/update`, data })
  },

  // 删除质检平台-承检资质
  deleteOrganizationQualification: async (id: string) => {
    return await request.delete({ url: `/qis/check-organization/delete?ids=` + id })
  },

  // 导出质检平台-承检资质 Excel
  exportOrganizationQualification: async (params) => {
    return await request.download({ url: `/qis/check-organization/export-excel`, params })
  },


  // 根据id获取单条数据
  getOrganizationQualificationById: async (id: number) => {
    return await request.get({ url: `/qis/check-organization/get?id=` + id })
  },


  // 修改单条数据
  updateOrganizationQualificationById: async (data: OrganizationQualificationVO) => {
    return await request.put({ url: `/qis/check-organization/update`, data })
  },

  deleteJgzz:async(id)=>{
    return await request.delete({ url: `/qis/organization-qualification/delete?ids=` + id })
  },

// 承检机构管理导出
  exportCjjgGl:async (params) => {
    return await request.download({ url: `/qis/check-organization/export-excel-org`, params })
  },

  getTimeList :async()=>{
    return await request.get({url:'/qis/sample-information/return-times'})
  },



  
  getReportDetail,
  downloadReport
}
